#ifndef APP_MSG_H
#define APP_MSG_H

#include <QObject>
#include <QLocalServer>

class AppMsg : public QObject
{
    Q_OBJECT
    AppMsg(const QString& id, QObject* parent = 0);
public:
    static AppMsg &get();
    virtual ~AppMsg();

    void sendMsg(const QString &msg);
    bool start();

    QString getLastErrorString() const;
signals:
    void hasMsg(const QByteArray &msg);

public slots:
    void onProcess();
    void onNewConnection();

private:
    QLocalServer m_server;
    QString m_serverId;

    QLocalSocket *m_socket = nullptr;
};

#endif // APP_MSG_H
